import java.util.Random;

public class Role {
    private String name;
    private int HP;
    private char gender;
    private String face;
    String[] boyfaces = {"风流倜傥", "气宇轩昂", "五官端正", "相貌平平", "一塌糊涂"};
    String[] girlfaces = {"沉鱼落雁", "倾国倾城", "身材姣好", "歪瓜裂枣", "惨不忍睹"};

    public char getGender() {
        return gender;
    }

    public void setGender(char gender) {
        this.gender = gender;
    }

    public String getFace() {
        return face;
    }

    public void setFace(char gender) {
        Random r = new Random();
        if (gender == '男') {
            int index = r.nextInt(boyfaces.length);
            this.face = boyfaces[index];
        } else if (gender == '女') {
            int index = r.nextInt(girlfaces.length);
            this.face = girlfaces[index];
        } else {
            this.face = "雌雄难辨";
        }
    }


    public Role() {
    }

    public Role(String name, int HP, char gender) {
        this.name = name;
        this.HP = HP;
        this.gender = gender;
        setFace(gender);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getHP() {
        return HP;
    }

    public void setHP(int HP) {
        this.HP = HP;
    }

    public void attack(Role role) {
        Random r = new Random();
        int hurt = r.nextInt(20) + 1;
        int remainHP = role.getHP() - hurt;
        remainHP = remainHP < 0 ? 0 : remainHP;
        role.setHP(remainHP);
        System.out.println(this.getName() + "对" + role.getName() + "造成" + hurt + "点伤害，" + role.getName() + "剩余血量为" + remainHP);
    }

    public void show() {
        System.out.println("姓名为：" + getName());
        System.out.println("性别为：" + getGender());
        System.out.println("血量为：" + getHP());
        System.out.println("样貌为：" + getFace());
    }


}
